import CATEGORIES from '../../utils/categories'

Page({
  data: {
    categories: CATEGORIES,
    accounts: [],
  },

  onShow: function () {
    this.queryData()
  },
  onShareAppMessage: function (res) {
    return {
      title: '账号密码管理助手',
      path: '/pages/index/index',//这里是被分享的人点击进来之后的页面
      imageUrl: '/images/share.jpg'//这里是图片的路径
    }
  },

  async queryData() {
    let arr = []
    for (let index = 0; index < CATEGORIES.length; index++) {
      const element = CATEGORIES[index];
      let data = wx.getStorageSync(element.name)
      if (data) {
        arr.push({ classify: element.id, sum: data.length })
      }
    }
    this.setData({
      accounts: arr,
    })
  }
});
